// pages/hospitalDetailInfo/hospitalDetailInfo.js
const app = getApp()
const util = require('../../utils/util.js')
const lbbService = require('../service/service.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  onLoad: function (options) {
    let hospitalInfo = JSON.parse(options.hospitalInfo);
    // let ruleList = hospitalInfo.equRuleShowInfoList;
    // let ruleArr = new Array();
    // for(var i=0;i<ruleList.length; i++) {
    //   let title = ruleList[i].title;
    //   if(title.indexOf('轮椅') == -1) {
    //     ruleArr.push(ruleList[i]);
    //   }
    // }
    // hospitalInfo.equRuleShowInfoList = ruleArr;

    this.setData({
      hospitalInfo: hospitalInfo,
      hospitalId:options.hospitalId
    })
    console.log(this.data.hospitalInfo.equRuleShowInfoList)
  },

  onReady: function () {

  },

  onShow: function () {

  },

  onHide: function () {

  },

  onUnload: function () {

  },
  makePhoneCall: function (e) {
    console.log(e)
    let phone = e.currentTarget.dataset.phone
    wx.makePhoneCall({
      phoneNumber: phone // 仅为示例，并非真实的电话号码
    })
  },
  add() {
    var that = this
    that.data.hospitalInfo.weight++
    that.setData({
      hospitalInfo: that.data.hospitalInfo
    })
  },
  reduce() {
    var that = this
    if (that.data.hospitalInfo.weight > 0) {
      that.data.hospitalInfo.weight--
      that.setData({
        hospitalInfo: that.data.hospitalInfo
      })
    }
  },
  submitQz() {
    var that = this;
    lbbService.updateHospitalWeight({
      hospitalId:that.data.hospitalId,
      weight: that.data.hospitalInfo.weight
    }, function (res) {
      wx.showToast({
        title: '修改成功',
      })
    })
  },
  /**
   * 跳转到医院拍照任务设置页面
   */
  navTakePhotoTaskSetting(e) {
    let that = this
    wx.navigateTo({
      url: '/pkgTask/pages/task-takephoto-hossetting/index?lbmId=' + that.data.hospitalId + '&confId=' + that.data.hospitalInfo.taskTimeConf.id 
      + '&startDate=' + that.data.hospitalInfo.taskTimeConf.startDate 
      + '&stepDay=' + that.data.hospitalInfo.taskTimeConf.stepDay 
      ,
    })
  },

})